#include <media/msm_cam_sensor.h>

static struct msm_camera_i2c_reg_array init_reg_array[] ={
	//========================================================
	//========================================================
	{0x6028,0x4000},	 //page pointer HW
	{0x6214,0x7971},
	{0x6218,0x0100},	 //clock on

	{0x6028,0x2000},	//pager pointer
	{0x602A,0x448C},
	{0x6F12,0x0000},
	{0x6F12,0x0000},
	{0x6F12,0x0448},
	{0x6F12,0x0349},
	{0x6F12,0x0160},
	{0x6F12,0xC26A},
	{0x6F12,0x511A},
	{0x6F12,0x8180},
	{0x6F12,0x00F0},
	{0x6F12,0x2CB8},
	{0x6F12,0x2000},
	{0x6F12,0x4538},
	{0x6F12,0x2000},
	{0x6F12,0x1FA0},
	{0x6F12,0x0000},
	{0x6F12,0x0000},
	{0x6F12,0x0000},
	{0x6F12,0x0000},
	{0x6F12,0x2DE9},
	{0x6F12,0xF041},
	{0x6F12,0x0546},
	{0x6F12,0x1348},
	{0x6F12,0x134E},
	{0x6F12,0x018A},
	{0x6F12,0x4069},
	{0x6F12,0x06F1},
	{0x6F12,0x2007},
	{0x6F12,0x4143},
	{0x6F12,0x4FEA},
	{0x6F12,0x1138},
	{0x6F12,0x0024},
	{0x6F12,0x06EB},
	{0x6F12,0xC402},
	{0x6F12,0x0423},
	{0x6F12,0x3946},
	{0x6F12,0x4046},
	{0x6F12,0x00F0},
	{0x6F12,0x1EF8},
	{0x6F12,0x25F8},
	{0x6F12,0x1400},
	{0x6F12,0x641C},
	{0x6F12,0x042C},
	{0x6F12,0xF3DB},
	{0x6F12,0x0A48},
	{0x6F12,0x2988},
	{0x6F12,0x0180},
	{0x6F12,0x6988},
	{0x6F12,0x4180},
	{0x6F12,0xA988},
	{0x6F12,0x8180},
	{0x6F12,0xE988},
	{0x6F12,0xC180},
	{0x6F12,0xBDE8},
	{0x6F12,0xF081},
	{0x6F12,0x0022},
	{0x6F12,0xAFF2},
	{0x6F12,0x4B01},
	{0x6F12,0x0448},
	{0x6F12,0x00F0},
	{0x6F12,0x0DB8},
	{0x6F12,0x2000},
	{0x6F12,0x34D0},
	{0x6F12,0x2000},
	{0x6F12,0x7900},
	{0x6F12,0x4000},
	{0x6F12,0xD22E},
	{0x6F12,0x0000},
	{0x6F12,0x2941},
	{0x6F12,0x40F2},
	{0x6F12,0xFD7C},
	{0x6F12,0xC0F2},
	{0x6F12,0x000C},
	{0x6F12,0x6047},
	{0x6F12,0x4DF2},
	{0x6F12,0x474C},
	{0x6F12,0xC0F2},
	{0x6F12,0x000C},
	{0x6F12,0x6047},
	{0x6F12,0x0000},
	{0x6F12,0x0000},
	{0x6F12,0x0000},
	{0x6F12,0x0000},
	{0x6F12,0x30D2},
	{0x6F12,0x029C},
	{0x6F12,0x0000},
	{0x6F12,0x0001},

	{0x602A,0x7900},   // Alpha control, added on 150106
	{0x6F12,0x4000},   // Gain_0__1_"
	{0x6F12,0x3000},   // Gain_0__2_"
	{0x6F12,0x2000},   // Gain_0__3_"
	{0x6F12,0x1000},   // Gain_0__4_"
	{0x6F12,0x4000},   // Gain_1__1_"
	{0x6F12,0x3000},   // Gain_1__2_"
	{0x6F12,0x2000},   // Gain_1__3_"
	{0x6F12,0x1000},   // Gain_1__4_"
	{0x6F12,0x4000},   // Gain_2__1_"
	{0x6F12,0x3000},   // Gain_2__2_"
	{0x6F12,0x2000},   // Gain_2__3_"
	{0x6F12,0x1000},   // Gain_2__4_"
	{0x6F12,0x4000},   // Gain_3__1_"
	{0x6F12,0x3000},   // Gain_3__2_"
	{0x6F12,0x2000},   // Gain_3__3_"
	{0x6F12,0x1000},   // Gain_3__4_"
	{0x6F12,0x0100},   // GainThr_0_"
	{0x6F12,0x0200},   // GainThr_1_"
	{0x6F12,0x0400},   // GainThr_2_"
	{0x6F12,0x0800},   // GainThr_3_"

	{0x602A,0x43F0},
	{0x6F12,0x0128},   // Ex_Reg{0x_u{0xMinDRClneq{0xizeX
	{0x6F12,0x00DC},   // Ex_Reg{0x_u{0xMinDRClneq{0xizeY
	{0x6F12,0x5590},   // Ex_Reg{0x_u{0xMinDRClneq{0xizePowXd2
	{0x6F12,0x3644},   // Ex_Reg{0x_u{0xMinDRClneq{0xizePowYd2
	{0x602A,0x1B50},
	{0x6F12,0x0000},
	{0x602A,0x1B54},
	{0x6F12,0x0000},
	{0x602A,0x1B64},
	{0x6F12,0x0800},
	{0x602A,0x1926},
	{0x6F12,0x0011},
	{0x602A,0x14FA},
	{0x6F12,0x0F00},
	{0x602A,0x4472},
	{0x6F12,0x0102},
	
	//Mapped Median Filter ON
	{0x602A,0x195E},
	{0x6F12,0x99BF},
	{0x602A,0x19B6},
	{0x6F12,0x99BF},
	{0x602A,0x1A0E},
	{0x6F12,0x99BF},
	{0x602A,0x1A66},
	{0x6F12,0x99BF},          																							
				   
	{0x6028,0x4000},
	{0x0B04,0x0101},																		
	{0x3B22,0x1110},																
	{0xF42E,0x200C},												
	{0xF49E,0x004C},													
	{0xF4A6,0x00F0},										
	{0x3AFA,0xFBF8},
	{0xF49C,0x0000},
	{0xF496,0x0000},
	{0xF476,0x0040},
	{0x3AAA,0x0205},
	{0x3AFE,0x07DF},
	{0xF47A,0x001B},
	{0xF462,0x0003},
	{0xF460,0x0020},
	{0x3B06,0x000E},
	{0x3AD0,0x0080},
	{0x3B02,0x0020},
	{0xF468,0x0001},
	{0xF494,0x000E},
	{0xF40C,0x2180},
	{0x3870,0x004C},
	{0x3876,0x0011},
	{0x3366,0x0128},
	{0x3852,0x00EA},
	{0x623E,0x0004},
	{0x3B5C,0x0006},

	{0x3A92,0x0807},
	{0x307C,0x0430},
		

};

static struct msm_camera_i2c_reg_array res0_reg_array[] = {

	// ExtClk : 					24	MHz
	// Vt_pix_clk : 	  440	MHz
	// MIPI_output_clk :  1272	Mbps
	// Crop_Width : 	  4216	px
	// Crop_Height :	  3128	px
	// Output_Width :	  4208	px
	// Output_Height :	  3120	px
	// Frame rate : 	  30.06 fps
	// Output format :	  Raw10
	// *Pedestal :		  0
	// *Mapped BPC :	  On
	// *Dynamic BPC :	  Off
	// *Internal LSC :	  On
	// H-size : 		  4592	px
	// H-blank :		  384	px
	// V-size : 		  3188	line
	// V-blank :		  68	line
	// Lane :			  4 lane

	//========================================================
	//Mode seting
	//========================================================
	{0x6028,0x2000},
	{0x602A,0x14F0},
	{0x6F12,0x0040},	 // #gisp_uOutPedestal
	{0x6F12,0x0040},	 // #gisp_uHvbinOutPedestal
	{0x602A,0x192C},
	{0x6F12,0x0001},	 // BPC block off
	{0x6028,0x4000},
	{0x0344,0x0008},	 // #smiaRegs_rw_frame_timing_x_addr_start	 4
	{0x0346,0x0008},	 // #smiaRegs_rw_frame_timing_y_addr_start	 4
	{0x0348,0x1077},	 // #smiaRegs_rw_frame_timing_x_addr_end	 4219
	{0x034A,0x0C37},	 // #smiaRegs_rw_frame_timing_y_addr_end	 3131
	{0x034C,0x1070},	 // #smiaRegs_rw_frame_timing_x_output_size  4208
	{0x034E,0x0C30},	 // #smiaRegs_rw_frame_timing_y_output_size  3120

	{0x0900,0x0111},	 //#smiaRegs_rw_binning_type
	{0x0380,0x0001},	 //#smiaRegs_rw_sub_sample_x_even_inc
	{0x0382,0x0001},	 //#smiaRegs_rw_sub_sample_x_odd_inc
	{0x0384,0x0001},	 //#smiaRegs_rw_sub_sample_y_even_inc
	{0x0386,0x0001},	 //#smiaRegs_rw_sub_sample_y_odd_inc
	{0x0400,0x0002},	 //#smiaRegs_rw_scaling_scaling_mode
	{0x0404,0x0010},	 //#smiaRegs_rw_scaling_scale_m
	{0x0114,0x0300},	 //#smiaRegs_rw_output_lane_mode
	{0x0110,0x0002},	 //#smiaRegs_rw_output_signalling_mode

	{0x112C,0x0000},	 //#smiaRegs_ro_clock_limits_min_vt_pix_clk_freq_mhz
	{0x112E,0x0000},	 //
	{0x0136,0x1800},	 //#smiaRegs_rw_op_cond_extclk_frequency_mhz		// 24MHz
	{0x0304,0x0006},	 //#smiaRegs_rw_clocks_pre_pll_clk_div				// 6
	{0x0306,0x006E},	 //#smiaRegs_rw_clocks_pll_multiplier				// 110
	{0x0302,0x0001},	 //#smiaRegs_rw_clocks_vt_sys_clk_div				// 1
	{0x0300,0x0004},	 //#smiaRegs_rw_clocks_vt_pix_clk_div				// 4
	{0x030C,0x0004},	 //#smiaRegs_rw_clocks_secnd_pre_pll_clk_div		// 4
	{0x030E,0x005A},	 //#smiaRegs_rw_clocks_secnd_pll_multiplier 		// 106
	{0x030A,0x0001},	 //#smiaRegs_rw_clocks_op_sys_clk_div				// 1
	{0x0308,0x0008},	 //#smiaRegs_rw_clocks_op_pix_clk_div				// 8

	{0x0342,0x11F0},	 //#smiaRegs_rw_frame_timing_line_length_pck			 4592
	{0x0340,0x0C74},	 //#smiaRegs_rw_frame_timing_frame_length_lines 		 3188
	{0x0202,0x0200},	 //#smiaRegs_rw_integration_time_coarse_integration_time 512
	{0x0200,0x0400},	 //#smiaRegs_rw_integration_time_fine_integration_time	 1024
	{0x0204,0x0020},		//#smiaRegs_rw_analog_gain

	{0x0B04,0x0100},	 //#smiaRegs_rw_isp_mapped_couplet_correct_enable
	{0x0B08,0x0000},	 //#smiaRegs_rw_isp_dynamic_couplet_correct_enable
	{0x0B00,0x0080},	 //#smiaRegs_rw_isp_shading_correction_enable

	{0x3B3C,0x0107},	 //#fe_isp_dadlc_bReadNvmFadlcActiveFactor
	{0x3B34,0x3030},	 //#fe_isp_dadlc_FadlcActiveFactorShGrR
	{0x3B36,0x3030},	 //#fe_isp_dadlc_FadlcActiveFactorShBlGb
	{0x3B38,0x3030},	 //#fe_isp_dadlc_FadlcActiveFactorLongGrR
	{0x3B3A,0x3030},	 //#fe_isp_dadlc_FadlcActiveFactorLongBlGb
	{0x306A,0x0068},	 //#smiaRegs_vendor_gras_otp_address

};

static struct msm_camera_i2c_reg_array start_reg_array[] = {
  { 0x0100, 0x0100 },//REG[0x0100]=0x01 stream on,REG[0x0101]=0x03 mirror
};

static struct msm_camera_i2c_reg_setting init_reg_setting[] = {
  {
    .reg_setting = init_reg_array,
    .size = ARRAY_SIZE(init_reg_array),
    .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
    .data_type = MSM_CAMERA_I2C_WORD_DATA,
    .delay = 0,
  },
  {
    .reg_setting = res0_reg_array,
    .size = ARRAY_SIZE(res0_reg_array),
    .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
    .data_type = MSM_CAMERA_I2C_WORD_DATA,
    .delay = 0,
  },
  {
    .reg_setting = start_reg_array,
    .size = ARRAY_SIZE(start_reg_array),
    .addr_type = MSM_CAMERA_I2C_WORD_ADDR,
    .data_type = MSM_CAMERA_I2C_WORD_DATA,
    .delay = 0,
  },
};



